import {getFloor, getNav} from '@/api'
import {getBanner} from '@/api'

const actions = {
    async queryNav({commit}) {
        const nav = await getNav()
        if (nav.code === 200) {
            commit('saveNav', nav.data)
        }
    }, async queryBanner({commit}) {
        const banner = await getBanner()
        if (banner.code === 200) {
            commit('saveBanner', banner.data)
        }
    }, async queryFloor({commit}) {
        const floor = await getFloor()
        if (floor.code === 200) {
            commit('saveFloor', floor.data)
        }
    }
}
const mutations = {
    saveNav(store, data) {
        store.navList = data
    }, saveBanner(store, data) {
        store.bannerList = data
    }, saveFloor(store, data) {
        store.floorList = data
    }
}
const state = {
    navList: [], bannerList: [], floorList: []
}
const getters = {}

export default {
    namespaced: true, actions, state, mutations, getters
}